<template>
	<view class="qiHome">
		<view style="width: 40px; height: 40px; border-radius: 50%; border: #fff solid 2px; position: fixed; z-index: 1; right: 10px; top: 40px; text-align: center; line-height: 36px; box-sizing: border-box; color: #fff; font-size: 16px;"
		@click="tippage()"
		>
			{{second}}
		</view>
		<image :src="imageUrl" mode="aspectFill" style="width: 750rpx;height: 100vh;"></image>
	</view>
</template>

<script>
	import {
		getStart
	} from "@/common/config/request.js"
	export default{
		data(){
			return {
				imageUrl:"",
				second:0,
				timeStop: '',
				time: -1
			}
		},
		onLoad() {
			this.getHome()
		},
		onShow() {
			this.timeStop = ''
			this.getHome()
		},
		methods:{
			getHome(){
				getStart({}).then(res=>{
					console.log(res)
					if(res.data.code==1){
						this.imageUrl=res.data.data.image
						this.second=res.data.data.second
						// var that=this
						
							this.daojishi(res.data.data.second)
						
					}
				})
			},
			daojishi(starttime){
				if(starttime==0){
					console.log(this.second)
					return  uni.reLaunch({
						url:'/pages/index/index'
					}) 
				}
				this.timeStop = setTimeout(()=>{
					console.log('jixu22222222222222222222222222')
					if (this.time != 0) {
						this.daojishi(starttime)
					}
				},1000)
				// setTimeout(this.daojishi(),1000);
				starttime--;
				this.second=starttime	 
			        // document.getElementById("id2").innerText=starttime;
				},
			tippage () {
				clearTimeout(this.timeStop)
				console.log('tingzhi11111111111111111111111111111111111111')
				this.time = 0
				this.daojishi(0)
				// uni.reLaunch({
				// 	url:'/pages/index/index'
				// }) 
			}
		}
	}
</script>

<style lang="scss" scoped>
	.qiHome{
		width: 750rpx;
		height: 100vh;
		image{
			width: 100%;
			height: 100%;
		}
	}
</style>
